cleanup, readability pass

store config path in global var;
`write_config()` responsible for writing config via [heredoc](http://www.tldp.org/LDP/abs/html/here-docs.html).