adds better var names, revises some comments