Added support for blocking in authentication. Error handling has also been improved small.