Fixed bugs found by Eran