Fix typo and improve cleanup