It might take me a while, and it may not be much simpler (you would still need most of the code), but I'll give it a try.