I agree with others. One thing to know about these engines is their are noising sewing machines. Timing chain chatter, valve noise, injector clicks, etc. When brand new they didn't make all these noises, but using the noise as indication of a problem has shown to be fruitless, lol.
I would get a second opinion on what needs to be fixed. Used engines I've seen run from $500~$900. I believe in 2004 is when various little parts changed, like removal of oil warmer, different PCV valve, etc. Nothing major, but it would make life easier to find an 2000~2003 motor from a 5 speed.
It's possible the timing is off, but I'd imagine more issues being an interference engine. If you know of a good mechanic and you had the choice between rebuilding the top end vs find a used motor for the same price I'd go with a good repair.
My Daily: 2000 5MT no A/C
My Project Car: 1985 Celica V6.