Merge pull request #946 from ChuckRozhon/fix_cast_bug Fixed bug introduced in PR#803 caused by casting