First pass to remove as many of the "foreach" loop logic as I could. Tweaked scripts where I could to check for "tags" instead of foreach loops.