Added abstract base class and code refactor