Cleanup utils

Fix database connections and query building
Removed some extra utilities
Added some documentation