Fix issue #55 avoid recursion, and fix the way dynamic reference parameters were looking for elements