DeleteThread refactoring (fixed)