Small fix to copyObject