Added db trimming to keep database a reasonable size.