code cleanup, and test on failure