Fixed bug with double flushing of error response