implements authentication. other small fixes