Regroup all queries in one place.

see #589
Few fixes in the postgres backend.

see #589
Adding some comments.

see #589
Merge branch '1.1.x' into refactoring/amavis_queries
Merge branch '1.1.x'