More port handling fixes