Refactoring; handle settings better