fixed mispellings, moved a few variables around
tidied up annotations