Overhaul of extend code and inheritance pattern.