Query: improvements for stats collection.

Histograms:
- Bucket is now a static class.
- Added bucket accessors.
- Added method to get all nonempty buckets from a histogram.
- Added method to get summary stats for whole histogram.
- Added tests.
Categories:
- Added methods to get histograms by category.
- Added tests.
Statistics:
- Fixed getMax method (used to return min!)
Query: An unbound input socket is now an error, not a warning.
Query: Exceptions from tile workers are now propagated to master thread.