Optimised classManager to include groups instead of going through everything.