Hideous but working Category/Subcategory functionality