Changed lock to support recursion

Since the cache reenters a lock (in GetKeyLastChange that was created in CheckDependencies), we need to allow recursion.  Or else refactor some of this other stuff, which seems more destabilizing.