Finally fix fixagent function.