fixed mispellings and did minor refactorings