Refactoring so the db can be closed on shutdown.
delete some files.