several improvements in calculations