Fixed object casting bug