Re-arranged elem scope because it messes up the entity links