Turn out that this function is not the most expensive one. We should cache "balances" first because it seems to be the most expensive function, specially when the number of bills grow.

Caching could be a nice idea, but maybe outside of scope for this pull request ?
By the way performance have been improved a lot by the last commit :)