Fix a bug with the shift cost function.