Better error checking for ports.