Fix caching Bug.

Using WeakValueDictionary was a bad choice. It worked whilst we
kept around schemes. But not any more.
Use same key for cache and database (md5)
Minor tuning (remove == for boolean compare)