Fixed #7 - improve session handling