Cleaned up balances code