Fixed delete_thread