Attempt to improve performance of state res v2 algorithm.