Cost calculation tidy up.
Fixed templates