Minor improvements of error handling and port