Added patch for casting bug from 192b979c57aa0b9a2df4f11ad4851ce4fbf5d38b