some refactoring and added exception support for Quadrillion