Fix a bug in how alternative ports are handled.