Fixed a typo and an infinite loop.