Changed SessionFactory logic