Drop borrow of port earlier to fix refcell borrow issue.