Better handling of settings
Remove unused code