Validate incoming port value in preferences, fixes #78