fixes from dmitry for latest bug.