Fixed a bug in the logic, that could cause things that should have been deleted to remain. Fixed a minor memory leak. Fixed a bug that could cause an unnecessary (empty) deleting revision to be added.