#433 [WIP] Refactored all uses of max revisions queries to joins

fixes #433