Prevent setting headers after they are sent
Merge pull request #589 from wpreul/master

Prevent setting headers after they are sent