Better variable names, comments, and a bugfix