cleanup commented code and add some comments