Cleaned up code a little and corrected the connections.