Fix bugs introduced in previous commit