move most of Session into an implementation file