Initial socket implementation
Thread safety and logging changes