Added a few comments and changed a (local) variable name.