Allow null query to be built

closes #156
Reformat code and organize imports