Dvogonen/making settings type safe

Ready for merge.
This was brutal. Now I am going to sleep.