Refactor to make settings work properly.