Cleaned up reconnection logic. Organized the code structure in ControllerActivity.