add an error mako template, and some other fixes