Fix bugs in the previous commit