query: register queries like events
Also register queries with a QueryType that allows us to check if the event is sent in the right direction. Add a serialized query type because we will need this for the allocation query. Remove the QueryTypeDefinition stuff, it is not used anymore and we now use custom queries and separate API for them. Update defs.