Refactored object pool.

Changed object pool interface to simplify use. Replaced object pool integer indices with type-safe element-specific indices. Updated all code using the old object pool interface.