fix incorrect destruction of empty arrays