Render effect templates in the right order always

Tidied up the code while at it.