Found the order for checking used variables was off. Moved check to after nested plans.