fixes by Andrei Brazhuk