Refactoring and enhance some features.