refactored pickling of sessions