Pep 8 compliance and some error handling