Calculate cache values before writing.
Fix DeclContext comparison.