fix for writing headers after body is sent.