code optimizations per Mike Schmalle's advice. Removed iterators and used for(:) instead, used getCategory(type), etc methods