Implement pmap_alloc/alloc_contiguous/free and some fixes