back-ported the tape code from 4.1.0.