database instantiation tool and minor refactorin