extended transformations of flags with transform and residual computation