Fixed a typo and added some clean-up code