We were running out of local refs when there are lots of devices. Instead of deleting every single local ref, create a local stack frame. This operation is inexpensive so doesn't add a high overload and keeps the code clean instead of deleting every single local ref.