some improvements to temlates