Improved port binding conversion rules, fixed bugs, added unit tests