flags and data write

ori must work now