Corrects some bugs remaining after previous commit