[optimization] Removed some useless codes. and some refactoring.