Fix formatting in render_template function
Fix case-consistency of exception message in apply function