Make use of NDB caching. Fixes #605