Handling connection better. Removing debug code.