Correct some bugs introduced in the last commit