clean up scopes, contexts, and blocks