Refactored some common functionality into abstract base classes.