better header handling + customizable 500 support for JSON