Fixed the connection bug and cleaned up some stuff.