need to duplicate attributes instead of copying them

- code has been stress-tested for memory leaks, memory usage remains stable