Fix a bug with recording of port