Fixed #517
Fixed rounding errors