Fix bugs introduced with c9594b73c1d4d579cddf366f575eb36e0c067327