Corrected bug and added generation of BaseClasses