Polymorphism support; pretty much a complete rewrite.