performance improvements and bug fixes
changed Double to BigDecimal