Housekeeping

I've added commenting to make the code more readable.