Fixes around error 500 handling