Fixed not all the leaves being checked properly.