Fix code generation to properly generage the right scope annotations in the right places.  Next to do consistency analysis.