pull in leventov's fixes