Fix for bug #0000226.  Also added a couple other safety checks.
Fix for bug #0000226.  Also added a couple other safety checks.

--HG--
branch : v1-6

digimatic/ogre,digimatic/ogre,digimatic/ogre,digimatic/ogre,digimatic/ogre,digimatic/ogre,digimatic/ogre