fix Core.ToBackend datatype and free var implementation