Improve config_gen script

Motivated by #199.