Made nbt_doDTW more memory efficient