add FLAG_PARENT, detect template error when scan()