Added session library, fixed bugs