Make get-total-cost use global variables. Plus minor updates.