Flake8 style fixes
Added/fixed error handling