Pool fixes

Fixes a race condition and prevents pool from entering invalid state after an error using batch operations.