Issue 1021

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