Preliminary support for visual sorting. Refactored some code. Got unit
tests working with dynamic templates.