Improve cache handling and model

Improve the cache handling to invalidate caches when objects are altered.

Fill in missing methods in the model.