Some more refactoring
Test for directory before removing it