Move authentication into separate modules and fix PEP8 compliance.