rework last patch to make code identical to 0.98/master