[IMP]Some refactoring in code.