Fix overzealous "cleanup" ;)

This code really needs to have tests written. Pull requests please...