Thread deleted, and cleaned code