Changed ScaledCost class to a helper function

To fix issue #272