Refactored settings handling. #160