some fixes by Shlomi Fish