Added factory to build classes dynamically