fix bugs in memory pool