added flags and fixes