remove obsolete states, add support for product type, fix flags parsing