refactored query building slightly
minor style update
improved query building supporting nested boolean operators and type:* conditions