add explicit cast in finalize_object