Fixed query in several build_layer() implementations.
Merge pull request #345 from opdemand/344-layer-query-fix

Fixed #344 - fixed query in several build_layer() implementations.