Updated HTTP 500 error handling. Much more stable now.