Fixes errors when renaming tables