Added caching of results from isValid transition.

When using my perfect action model it went from

10000 updates in 1101ms

to

10000 updates in 46ms

So it appears to speed things up a bit...