Fix bugs introduced in 51ab3991f24a0ba0bca71189bc32f7a64886f064