added residual proportion to output
removed dead code
revised percent contribution calculation