Fixed a bug with the -tdo option. The -ref still has some issues.