Refactoring: extract class. Move the non-implementation specific code (most of it) to an abstract super class. I increased visibility for most of the fields from private to protected, so that they can be used from the sub class just as before.