Fix variance rounding error and minimum variance bug