change class hierarchy to common base classes