added arbitrary-precision and fixed small bugs