Cache validation result.

Rebased version of #303/#290
Huh? :)