Resolve header mauling during MITM, cleanup

Import upstream changes in lib and module.
Resolve header subs (old code was a mess), creates duplicate hash
and assigned gsubed string values from it to req.headers[key].
Remove uneccessary returns.

@s1nn3r: tested as per your method and working, thanks for finding
the bug.