I agree that the code is messy, but is actually somewhat efficient, and represents well some of the weird behavior of the original game. So I am a little bit undecided w.r.t. using it. But in any case, I don't have enough time to push this initiative.
But if you push it, an put the code somewhere I can access, I'm willing to help!!