Fixed registration and added authentication.