Clean up socket and formatting issues