Move configuration into a function + small fixes

* Centralize configuration
* pep8 fixes for whitespace
* Add missing log messages for exit codes

Change-Id: I7f596f7507148e35e68f325a4bb6f88cd648207a