Cleanup and reorder connection.c