Code and documentation cleanup

...and making the exceptions PEP8-compliant