Ledger cleanup

Remove a number of `static` functions used to calculate indices from `Ledger` and make them free. The first commit is a purely "mechanical" cleanup. The second involves a micro-optimization.

Reviews: @JoelKatz, @josh-ripple