Improve assertion for access to nonlocal elements