More XML hacking for references. Split some of our code into identifiable and smaller files.