fixed 3 critical issues: clone data arrays that are passed in.