Merge pull request #3 from yarinb/master

Minor fix when remapping references on invalid elements