improvements to automatic profit and margin calculations