Added helper functions to allocate and release memory pools

Ignore-this: 483eeceaa1c83cb5c146a902aa0c0883

darcs-hash:20130917160806-56b4d-ab9032c71e2be119e134fd0c10af2f13d8eed6b9
Removed duplicated check

Ignore-this: e8837cc94bf110191e1f46c49447fbf1

darcs-hash:20130917160821-56b4d-ef7041ec1dfa8ec54ffb853795e8f5864e95bbe4