Added check for None when returning port number.