Improved some variable names, and added some explanatory comments.