Improved templates and fixed bugs
Merge