Propagate sock errors.
Misc fixes

Fix runtime errors due to missing setMode.
Clean up message handling a little - still want to do a big refactor.