physical memory allocation and fixed some bugs