Fixed issue with port rewriting, fixes #21 and might help with #12.

Thanks @freakout42