Cache classes upfront where possible to reduce iterations