Implements "Steven's way" in the sql end of things. Ordering/activation
still needed. Also, may need more indexes to speed joins and/or
grouping.