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.