Some typos fixed, minor refactoring.