removing unused variables and parameters, improved comments