Fix valid port check.