Fixed errors in speedCalc

Also added comments to various functions