Major changes/refactoring:
* removed most dynamic polymorphism in favor of templates and static dispatching