Renamed gen_sql() to acct_bal_sql(). Removed unused get_child_balance.
Added comments.