fix some array copying issues