Added reflection to assign class. This should probably move to a factory.