Refactor/active relation queries

The backend interface triggered a huge amount of individual queries. Especially when dealing with many events and event_sources per owner_type. Let's take some load of the database! 

This pull requests is a first step towards less queries while still trying to be database agnostic. It basically makes of a database's group functionality and building custom result hashes.