More technical debt cleanup.
Also check that the port number is in a valid range...