rewrote insertLinks stuff, added some FIXMEs