Some fixes for templates