Fixed bug with unit cost not calculated for one last tick.