Fix or error in derivative of Xi
Tidy up