Only memoize boards for which a final state has been found. Plus optimizations.