Lots of comments like "what does this do?"
These should be replaced with comments explaining what that bit of code does.
Looks OK to me.