Refactored code to allow abstract classes and inheritance etc