re-write query processor to be more readable; support reversed range lookup queries
fix several mishandled buffer boundary check in files
Merge branch 'master' into small_disk