Deadlock solution + ordering heuristic: put everything together and it works!