Add new settings, clean some code, fix bugs