Fix issues 3863, 3864

Changes:

- Delete variables in the datastore that were deleted by the session
- Initialize `old_globals` separately and not as a copy of the statement module. I tried `copy.deepcopy` but it [doesn't work on types that reference a module](http://stackoverflow.com/questions/1941887/how-can-i-debug-a-problem-calling-pythons-copy-deepcopy-against-a-custom-type) and I wanted to avoid monkeypatching a private API.

Fixes [issue 3863](https://code.google.com/p/sympy/issues/detail?id=3863) and [issue 3864](https://code.google.com/p/sympy/issues/detail?id=3864).