Move autodetect handling to the library.

This is consistent with how we expand the settings. Also add comments to
separate code that deals with settings and registration parameters.