Fix several bugs in render and templator.