Add data structure functions; add copy test
Cleanup and a bug fix