fix some bugs with the new templating code, improve ERB error logging