Improve port input error handling