The overly complicated subroutines `rhs_balance` and `rhs_balance_source` should be refactored to make intent clear and reduce code duplication.