fixed wedge

changes wedge to have 3 parameters and add the keys and references at
the end of the key and reference arrays and sorts it instead of miller's
stupid convoluted way of doing things