Added thread removal functionality