Changed bigdecimal to double, fixed bugs