Re-added the part where it tries to remove all global variables first.