Refactored code further in trending and storage.