Cache giving, pledging and receiving amounts

This should improve performance, and make it easier to solve #1127.