Cleanup in 'terminate' methods.

In 'terminate' methods, reset dictionary / list variables and
class's __instance variable.

Misc cleanups.