Fix: a minor bug in setting the init value of global variables;
Fix: the using of global variables as looping varaible;
Fix: code snippet printing for errors.