Refactor config.{c,h}

The config code was getting a little out of hand. This PR refactors the code a bit and reorders variables and functions according to the order they are displayed in the settings window. Config options were also moved into a config struct to have them all in one place.