[IMP]Simplified some code,remove unused code and some comments.