Fix index mis-modify and delete trailing whitespace.