Feature/logic out of templates

Still a few more templates to fix, WIP.
FIXED