Fix bugs introduced by previous commit