Various changes and large fixes

Notably:
* Repaired lots of broken code which was previously commited untested
* Began POSIX socket API support