Added authentication.
Small refactoring.