am ce209462: Merge "Fix some HandleScope bugs and add corresponding checks"

* commit 'ce209462cc1a7ce235e5ac0d0e6db6b402f73441':
  Fix some HandleScope bugs and add corresponding checks