Fix pool loop memory problems