Remove unsafe handling of element references

Should fix #68