Re-add main connection code.

Sans crendentials :)
Clean up organization.