Refactored, registration issue, custom baseclass

+ refactored for usage outside code gen
+ fixed pkgdef & build event for new pkgdef. Didn't register before.
+ support for custom base class