Got rid of duplicate code in subclasses.