Rework query

Most of queries are now based on its own struct.

 - fixes #19  
 - fixes #22