slightly refactored socket server; minor fixes;