Merge pull request #1652 from WalterBright/staging

Merge pull request #1413 from 9rnsr/x3011
Merge pull request #1645 from mxfm/b9438

Fix issue 9438 - Strange RefCounted stack overflow