Add better sharing support and other fixes.

Includes a few hotfixes and an improved system for sharing to allow
better caching should a shared image become popular.