Some cleanup and a little more explanatory commenting