Fix term reordering Closes #4294