Rewrite calculateDbgValueHistory to make it (hopefully) more transparent.