work on the decimal integration, and some refactoring

Signed-off-by: Alexander Skjolden <alex@plastboks.net>