refactor and add override notations

Some code refactoring.