Bugfix autorelease pool manager

Continue with pull request #6780.

Commit dbca937 will break AutoreleasePool test case.
Other commits fix it.

It may not be a bug, but a 'feature'. If that, explicit code/documentation should be added.

TestCase AutoreleasePool passed.