diff --git a/core/isolinux.asm b/core/isolinux.asm
index 2627c2d..a0910fb 100644
--- a/core/isolinux.asm
+++ b/core/isolinux.asm
@@ -1135,73 +1135,23 @@ all_read:
 ; (which will be at 16 only for a single-session disk!); from the PVD
 ; we should be able to find the rest of what we need to know.
 ;
-get_fs_structures:
-		mov eax,[bi_pvd]
-		mov bx,trackbuf
-		call getonesec
-
-		mov eax,[trackbuf+156+2]
-		mov [RootDir+dir_lba],eax
-		mov [CurrentDir+dir_lba],eax
-%ifdef DEBUG_MESSAGES
-		mov si,dbg_rootdir_msg
-		call writemsg
-		call writehex8
-		call crlf
-%endif
-		mov eax,[trackbuf+156+10]
-		mov [RootDir+dir_len],eax
-		mov [CurrentDir+dir_len],eax
-		add eax,SECTOR_SIZE-1
-		shr eax,SECTOR_SHIFT
-		mov [RootDir+dir_clust],eax
-		mov [CurrentDir+dir_clust],eax
-
-		; Look for an isolinux directory, and if found,
-		; make it the current directory instead of the root
-		; directory.
-		; Also copy the name of the directory to CurrentDirName
-		mov word [CurrentDirName],ROOT_DIR_WORD	; Write '/',0 to the CurrentDirName
+		call iso_mount
 		mov di,boot_dir			; Search for /boot/isolinux
-		mov al,02h
-		push di
-		call searchdir_iso
-		pop di
-		jnz .found_dir
-		mov di,isolinux_dir
-		mov al,02h			; Search for /isolinux
-		push di
-		call searchdir_iso
-		pop di
-		jz .no_isolinux_dir
+		call setcwd
+		jnc .found_dir
+		mov di,isolinux_dir		; Search for /isolinux
+		call setcwd
 .found_dir:
-		; Copy current directory name to CurrentDirName
-		push si
-		push di
-		mov si,di
-		mov di,CurrentDirName
-		call strcpy
-		mov byte [di],0	;done in case it's not word aligned
-		dec di
-		mov byte [di],'/'
-		pop di
-		pop si
 
-		mov [CurrentDir+dir_len],eax
-		mov eax,[si+file_left]
-		mov [CurrentDir+dir_clust],eax
-		xor eax,eax			; Free this file pointer entry
-		xchg eax,[si+file_sector]
-		mov [CurrentDir+dir_lba],eax
 %ifdef DEBUG_MESSAGES
 		push si
 		mov si,dbg_isodir_msg
 		call writemsg
 		pop si
+		mov eax,[CurrentDir+dir_lba]
 		call writehex8
 		call crlf
 %endif
-.no_isolinux_dir:
 
 ;
 ; Locate the configuration file
@@ -1706,6 +1656,90 @@ getfssec:
 		TRACER 'f'
 		ret
 
+;
+; setcwd: Set current working directory.
+;
+;  On entry:
+;	DI	-> directory name
+;  On exit:
+;	CF = 1	-> error
+;
+; On error, the old working directory is kept.
+;
+setcwd:
+		mov al,02h
+		push di
+		call searchdir_iso
+		pop di
+		stc
+		jz .err
+		mov [CurrentDir+dir_len],eax
+		mov eax,[si+file_left]
+		mov [CurrentDir+dir_clust],eax
+		xor eax,eax
+		xchg eax,[si+file_sector]
+		mov [CurrentDir+dir_lba],eax
+		mov si,di
+		mov di,CurrentDirName
+		cmp si,di
+		jz .ok
+		mov cx,FILENAME_MAX
+		push ds
+		pop es
+.copy:
+		lodsb
+		stosb
+		or al,al
+		loopnz .copy
+		mov byte [di-1],0
+		jnz .err
+.ok:
+		clc
+.err:
+		ret
+
+;
+; Read fs meta data and setup RootDir and CurrentDir.
+;
+;  On exit:
+;	CF = 1	-> error
+;
+iso_mount:
+		mov eax,[bi_pvd]
+		mov bx,trackbuf
+		call getonesec
+
+		mov eax,[trackbuf+156+10]
+		mov [RootDir+dir_len],eax
+		add eax,SECTOR_SIZE-1
+		shr eax,SECTOR_SHIFT
+		mov [RootDir+dir_clust],eax
+		mov eax,[trackbuf+156+2]
+		mov [RootDir+dir_lba],eax
+
+		push ds
+		pop es
+		mov si,RootDir
+		mov di,CurrentDir
+		mov cx,dir_t_size
+		rep movsb
+
+%ifdef DEBUG_MESSAGES
+		mov si,dbg_rootdir_msg
+		call writemsg
+		call writehex8
+		call crlf
+%endif
+
+		mov di,CurrentDirName
+		call setcwd
+		jnc .ok
+		mov word [CurrentDirName],ROOT_DIR_WORD
+.ok:
+		clc
+		ret
+
+
 ; -----------------------------------------------------------------------------
 ;  Common modules
 ; -----------------------------------------------------------------------------
