Better templates behaviour.

TODO:
- Write some tests which fail under previous behaviour.
- Fix
- Squash this commit