Templates & sorting, with fix to disappearing sort menu

This adds some small fixes to the sorting menu to #147.