Use correct context name.
Perform the edits in a separate string.
Emit missing semi-colon.
Don't emit the global variables (as global variables).
Insert init code for simple assignments.

It won't work for more complex assignments.