Some refactoring based on pullreview