add query builder

also some other improvements and tweaks
Merge pull request #6 from btfou/master

add query builder