Cache anonymous classes to avoid class missmatches