Improves handling of forwarded headers. Fix #2094

I hope this is alright.