refactored state, settings, etc.