Fixing a type casting bug.