These functions could use some commenting. What do they copy, where, what are the params?