Persist settings in UI

Also fix some bugs and move client-side settings code to a controller