Replace the instancedirectory variable with an Instance class that holds
the directory and has a .path() to get paths relative to the instance
directory.
Change the ugly global slaves object to be a member of the db object and
implement the items database as a separate integrety verifying class in
lib/database.