Hmm, the point about functions is more personal preference as I think passing by Ref on the whole makes things difficult to follow as it's not easy to see what's going on.
Consider:
Without digging through code, it's not at all easy to see what's being changed, contrast that with:
Nothing is edited in the function, rather a new array is returned - it makes the code much easier to follow.
FWIW you could make your code a hell of a lot more efficient by using a collection/dictionary. All this, would be a simple single function:
Bookmarks