If I have say 5 buffs on a target (which are stored in the state object) and then try and run a loop that is removing all of these buffs then I constantly get the message "infinite loop or long running process detected". It will remove up to two at once but anymore than that and I always receive the error message. On the rare occasion it will corrupt the state object. Here is the code that receives the chat message to delete all of the data stored in the object: on("chat:message", function(msg) { var cmd = "!StatusDelAll"; if (msg.type == "api" && msg.content.indexOf(cmd) !== -1) { //&& msg.who.indexOf("(GM)" !== -1)) { var CharID = ""; var Duration = 0; var statusName = ""; var loop = 0; var maxLoops = state.activeStatus.length; var cleanedMsg = msg.content.replace(cmd, ""); while (loop < maxLoops) { _.each(msg.selected, (function (obj){ //Pulls the selected ID token = getObj("graphic", obj._id); if (token.get("represents") == "") { CharID = token._id; } else { CharID = token.get("represents"); } if (obj._type == "graphic" && state.activeStatus[loop].CharID == CharID) { //only if the selected is a token StatusTracker.DelStatus(state.activeStatus[loop].CharID, state.activeStatus[loop].statusName, state.activeStatus[loop].Duration); //drop loop by 1 now that there is 1 less object in the array. loop = loop - 1; maxLoops = state.activeStatus.length; } })) loop = loop + 1; } } }); Here is the DelStatus function: StatusTracker.DelStatus = function(CharID, statusName, Duration){ var name = ""; var holder = ""; var loop = 0; var maxLoops = state.activeStatus.length; while (loop < maxLoops) { if (state.activeStatus[loop].statusName == statusName && state.activeStatus[loop].CharID == CharID) { var getName = findObjs({ _represents: CharID, _type: "graphic", }) _.each(getName, function(getname) { name = getname.get("name", holder); }) //StatusTracker.updateStatsPenalty(CharID, statusName) message = '<b style="color:red;">' + "'" +state.activeStatus[loop].statusName + "'" + '</b>' + " ends for " + name; StatusTracker.sendMessage(message, state.activeStatus.GMOnly, state.activeStatus[loop].statusDescript); var Value = state.activeStatus[loop].Value //Remove the relevant marker StatusTracker.delMarker(state.activeStatus[loop].CharID, state.activeStatus[loop].Marker); StatusTracker.updateStatsPenalty(CharID, statusName, Duration, Value) state.activeStatus.splice(loop,1); return; } loop = loop + 1; } } The 'updateStatsPenalty' function updates the characters attributes based on the spell buff that was just removed. (Too much code to post in here) If I try and remove more than 2 spell buffs at once then I receive the error message.