Refactoring on how databases are set and used.
Added deleting functions and general improvements.