Refactored database and dbdeploy support