Restructure code
Change database from per session global to global