Adding more socket options, cleanup connection logic