code cleanup for rendering templates