DATACMNS-578 - Speed up instance creation by generating Factory classes with ASM.

Refactoring according to code review.