Template and view fixes: round 2

See #450 for the original PR.