moved lots of options closer to where they're used
optimized query creation for range queries
added real padding support