Fix 500 template processing error
merged keto's work on better handler500