Refactor config attribute handling
Fix exception handling code in Py3

Closes #1