Fix handling of port flags.