Cache validation result.

Rebased version of #303/#290
Nope, these are the changes of #303 and #290