fixed NPE; added some helper methods for reflective class instantiation