Revised code to deal with settings. This version uses native types where possible to increase portability and ease of registry editing. It also deals with defaults.