Refactoring to remove redundant code (and for easier subclassing).
3 files changed