Updated several codes after refactoring.