Fixed method _release_ports to check if port exists before remove