Fix reference error and bug in console target.