Cleanup and started working on write_config()