fixed mmap-related bugs