fix using the wrong variable names, update comments, and put in some debugging echo...