Fix object casting