This should likely be done in the other updating functions of the `Database` class as well to avoid indexes and actual data appearing inconsistent during the write operations.