some fixes suggested by Shlomi