Add Mac OS X support for networking; better network code