Fix some bugs in pooling.