Large refactor of settings module