fixes from prof. Terekhov