More docstrings, reorganization/cleanup/bugfixes, add AuthenticationError