Minor optimizations

- Cache getClass results
- Remove additional forEach definition
- Remove property access before try-catch
Add @d10 as a contributor.