Fixed a few bugs
Improved queries