Refactor classes and try to avoid code duplication.
Move implementation into .cpp file.