Fix bug in copying