Submitted by GreyArt
A number of functions suffer from the erroneous conversion of Balancer V1s implementation.
The fixed implementation is provided below.
maxsam4 (Sushi) acknowledged
