Removing defs and references on clear()