make the code more efficient.
```
# file types: Wwise sound engine AKPK and BNK archives
# script type: extractor
# note 1: all files extracted as *.wem
# note 2: after extraction, parse with script
# for the soundbanks.xml or *.txt (if available)
#
# (c) by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get BNAME basename
getDstring IDENT 4
if IDENT == "AKPK"
	callfunction AKPK 1
elif IDENT == "1KCP" # The Saboteur (PC)
	callfunction AKPK 1
elif IDENT == "BKHD"
	callfunction BKHD 1
else
	print "Error: no valid Wwise sound pack"
	cleanexit
endif

startfunction AKPK
	set PC 0
	endian big
	get SIZE_HEADER long # data start offset
	get TEST long
	get FSIZE asize
	if TEST != 1
		reverselong SIZE_HEADER
		endian little
		set PC 1
	endif
	get BNAME basename
	string BNAME += " "

	goto 0xc
	get IDENT long
	set FOLDER_NAMES 1
	if IDENT == 0xc6
		set NBIAS 0x18
	elif IDENT == 0x14
		set NBIAS 0x1c
		set PC 1
	else
		set NBIAS 0x1c # also in PC versions
	endif
	goto NBIAS
	get NUM_FOLDERS long
	if NUM_FOLDERS > 10
		math NBIAS -= 4
		goto NBIAS
		get NUM_FOLDERS long
	endif
	savepos MYOFF
	set INFO NUM_FOLDERS
	math INFO *= 8
	math INFO += MYOFF # = start of names, will hold offset to jump to for TOC
	set ALLNAMES 0 # for ceil after names

	for i = 0 < NUM_FOLDERS
		goto MYOFF
		get OFF_NAME_FOLDER long
		math OFF_NAME_FOLDER += NBIAS
		get ID_FOLDER long
		savepos MYOFF
		goto OFF_NAME_FOLDER
		if PC == 0
			get NAME_FOLDER string
		else
			callfunction getPCstring 1
		endif
			strlen LENGTH NAME_FOLDER
			math ALLNAMES += LENGTH
			math ALLNAMES += 1
		string NAME_FOLDER += "/"
		string NAME_FOLDER += BNAME
		putArray 0 ID_FOLDER NAME_FOLDER
	next i
	if PC == 1
		math ALLNAMES *= 2
		math INFO += ALLNAMES
	else
		savepos INFO
		math INFO x= 4
	endif
	goto INFO
	set RUNS 1
	callfunction extract 1
	cleanexit
endfunction

startfunction BKHD
	get TEST short
	set REV 0
	if TEST == 0
		set REV 1
		endian big
	endif
	goto 4
	get SIZE_HEADER long
	savepos MYOFF
	math MYOFF += SIZE_HEADER
	get FSIZE asize
	if MYOFF == FSIZE
		print "bnk is empty"
		cleanexit
	endif
	goto MYOFF
	idstring "DIDX"
	get SIZE_DIDX long
	set FILES SIZE_DIDX
	math FILES /= 0xc
	set BIAS MYOFF # complete header
	math BIAS += SIZE_DIDX
	math BIAS += 16
	get BNAME basename
	for i = 1 <= FILES
		get DIDX long
		get OFFSET long
		math OFFSET += BIAS
		get SIZE long
		set NAME DIDX
		string NAME p= "%s.wem" DIDX EXT
		log NAME OFFSET SIZE
	next i
endfunction

startfunction getPCstring
	set NAME_FOLDER ""
	for s = 0
		get CHAR byte
		get NULL byte
		putVarChr NAME_FOLDER s CHAR
		if CHAR == 0
			break
		endif
	next s
endfunction
	
startfunction extract
	savepos INFO
	get NUM_FILES long
	if NUM_FILES == 0
		if RUNS == 1
			get NUM_FILES long
		else
			cleanexit
		endif
	endif
	print "extracting %NUM_FILES% files (number at offset %INFO%)"
	for i = 1 <= NUM_FILES
		get NAME_CRC long
		get MULTI long # in certain cases only
		get SIZE long
		if SIZE == 0
			get SIZE long
		endif
		get OFFSET long
		get ID_FOLDER long
		if OFFSET == 0
			set OFFSET ID_FOLDER
			get ID_FOLDER long
		endif
		#string NAME_CRC p= "0x%08x" NAME_CRC		
		if MULTI != 0
			math OFFSET *= MULTI
		endif
		savepos MYOFF
		if PC == 0
			endian big
		endif
		string NAME_CRC += ".wem"
		log NAME_CRC OFFSET SIZE
	next i
	math RUNS += 1
	callfunction extract 1
endfunction
```