Exception handling refactored, python 3 syntax everywhere