bufixes and added patchmemory