Removed remaining usage of Connection logic

All logic has been moved to Query. This way, query construction and query
execution is handled at the same point. This makes possible customizations
for various database.