Use a different random way of storing ns in element_name, fix memleak