function Janitor.Cleanup(a)if not a.CurrentlyCleaning then a.CurrentlyCleaning=nil local T=GetFenv(a)local X,F=T()while X and F do if F==true then X()else local a=X[F]if a then a(X)end end a[X]=nil X,F=T()end local J=a[IndicesReference]if J then table.clear(J)a[IndicesReference]={}end a.CurrentlyCleaning=false end end

function Janitor:Cleanup()
	if not self.CurrentlyCleaning then
		self.CurrentlyCleaning = nil

		local Get = GetFenv(self)
		local Object, MethodName = Get()

		while Object and MethodName do -- changed to a while loop so that if you add to the janitor inside of a callback it doesn't get untracked (instead it will loop continuously which is a lot better than a hard to pindown edgecase)
			if MethodName == true then
				Object()
			else
				local ObjectMethod = Object[MethodName]
				if ObjectMethod then
					ObjectMethod(Object)
				end
			end

			self[Object] = nil
			Object, MethodName = Get()
		end

		local This = self[IndicesReference]
		if This then
			table.clear(This)
			self[IndicesReference] = {}
		end

		self.CurrentlyCleaning = false
	end
end
