General code improvement
Improved class definition and use of inheritance