Refactored settings handling.