move some non mmap stuff out of maps.c