Made cost of transport calculations more robust