code clean up, remove commented code and add some comments