I think I might have done something right, headByRating and headByName both refer to the same address.
I have been drawing diagras working all day trying new things etc,
It looks like you have several problems here:
I'd recommend removing everything from this method and writing high-level pseudo code in its place. Then create a smaller method for each line of pseudo code. Smaller logical methods called inside insert will help it make sense.