Added logout method.
Fixed double authenticate.