fix template monstrosities
more refactoring