Measure calculation workarounds

rebased yoon's pull request, fixed test suite and errors