It sounds like you will have to spend some time disentangling the more complex entries.
The starting point (after making a backup) is to locate the situations where there are unapplied Cash receipts that match exactly to invoices (in other words, they should have been applied at the time of entry). Enter a $0.00 Receipt and "apply it" to both the cash receipt and invoice transactions. That will clear up a number of the entries and allow you to focus on the more complex situations.