Fix scoped session handling