Revert "Cleanup inheritance tree"

This reverts commit 3cbc101c089a4378eebf10cf419ee9ba276cf61b.
Improve casting