some order-of-operation changes, mostly for readability