Implement autocalc, fixes #2