Refactor port manager