Major refactoring of SPI base classes.