Refactor the way pacakge databases are handled