Improvements to templates.

Change-Id: If8fe6d41e7a4b3d7047a4a6840d7615cba6c56fe