Fixing more flag setting bugs