Cleanup response writer and include errors on Flush

Includes #26.
Still needs a unit test.