[BZ 1069545] More subcategory cleanup, removing unused code and fixing joined queries.