Fixed bugs and added full sub classing support.