A few stylistic changes and bug fixes