some code refactoring, managing preferences