Fixed casting of object with safe expectations