Don't instantiate references to non-instantiated elements - fixes #440