use a config file rather than globals

- exit with status 1 in case of errors
- update variable name style in main