Some NameError bug fixed