Change the definition of cost

Patch from John, test case updates from me.