Migrating code from the BlowTorch repository.