Extract rw_config into module, and clean it up a little.