Fixed several bugs regarding session authentication. Various other small improvements.