Add support for keeping intermediate values

fixes #8 on github