Adding flags and residual code