Add setting, fix bugs