Fixed bugs caused by renaming of variables