Fixing last bugs and oversights in database cache engine