Code Cleanup + Socket connection