Corrects some bugs