Readded some code from twill that shouldn't need modification and added support for extra headers