Fix bugs introduced by 150fe3e1d5 and 2dc2bcddcc