Correct some bugs from previous commit