Fix internal pool. Ensuure that all access is thread-safe. Eliminate O(n) counts and array traversals in favor of O(1) push/pop and scalar counters
Merge pull request #449 from cheald/fix_internal_pool

Internal pool fixes