General refactoring, add selection.