Add some manual timeouts for connect, and cleanup the code