[IMPROVED] Better handling of archived shares

Please check the appropriate ticket #1021 for details of the changes
made. Tested locally with shares created via INSERT.

Fixes #1021 after merge.
[IMPROVED] Debug logging for purgeArchive calls
Merge pull request #1029 from TheSerapher/issue-1021

Issue 1021