Dvogonen/making settings type safe

Ready for merge. This is a really big one, so I want someone else to push the button :-)
I have made all the major changes. There are a couple of minor things like outstanding like joystick calibration data. They still work, but are not protected by the global data object.