Move tail call optimisations to compile.c.

Needs more testing.