Fixed a miscounted reference and complex unresolved loop control flow.