Track references and normal elements separately in Cell

When building the dependency tree, we currently need to go through *all* elements of a cell,
even though we are mostly only interested in the references.

This commit saves the references and elements in separate lists, resulting in a potentially
huge speedup during save.