Fix a bug in affix tool, remove some unnecessary code.