It takes me a lot longer to explain the code than to write it.
We can do it piecemeal; tell me one or two things you don't understand and I'll try.