Added mmap and exception handling