First step to rework the session handling
Replaced a lot of deprecated calls by the new ones. (do not merge)
still improving the session handling - changed the intialization of the factory  (Merge at your own risk: I have not tested anything)