cleanup and commenting of code