Added calc-total-balance to query.
Did some renaming in other functions.