Refactored database instantiation.