moved parse_flags into state