Fixed totals bug and improved cache invalidation