Added the port guard to protect available_ports map.