I got a little confused in one place (line 191) because the meaning wasn't clear. I also changed a couple of other places to make it read more naturally.