local E={["\102\117\110\099\116\105\111\110"]=function(E)E()end,RBXScriptConnection=function(E)E:Disconnect()end;Instance=function(E)E:Destroy()end}local l={}l.__index=l function l.Mark(i,l)if E[typeof(l)]then i.trash[#i.trash+1]=l else error(("\077\097\105\100 \100\111\101\115 \110\111\116 \115\117\112\112\111\114\116 \116\121\112\101 \"\037\115\""):format(typeof(l)),2)end end function l.Unmark(l,E)if E then local i=l.trash for l=1,#i,1 do if i[l]==E then table.remove(i,l)break end end else l.trash={}end end function l.Sweep(l)local i=l.trash for l=1,#i,1 do local h=i[l]E[typeof(h)](h)end l.trash={}end function l.new()local E=setmetatable({},l)E.trash={}return E end return l.new()


local destructors = {
	['function'] = function(item)
		item()
	end;
	['RBXScriptConnection'] = function(item)
		item:Disconnect()
	end;
	['Instance'] = function(item)
		item:Destroy()
	end;
}

local Maid = {}
Maid.__index = Maid

function Maid:Mark(item)
	if destructors[typeof(item)] then
		self.trash[#self.trash + 1] = item
	else
		error(('Maid does not support type "%s"'):format(typeof(item)), 2)
	end
end

function Maid:Unmark(item)
	if item then
		local trash = self.trash
		for i = 1, #trash do
			if trash[i] == item then
				table.remove(trash, i)
				break
			end
		end
	else
		self.trash = {}
	end
end

function Maid:Sweep()
	local trash = self.trash
	for i = 1, #trash do
		local item = trash[i]
		destructors[typeof(item)](item)
	end
	self.trash = {}
end

function Maid.new()
	local self = setmetatable({}, Maid)
	self.trash = {}
	return self
end

return Maid.new()
