Delete empty ReferenceMarks

Overwriting empty ReferenceMarks is impossible, both from code and
from the UI. We now check to see if ReferenceMarks are empty in
setCode() and setText(). If they are, we delete them before
proceeding to ensure that we don't accidentally duplicate them.