Clean up code. And move the connection check to the 50 second mark.