Added database pruning functionality