added some missing code from cm's media-caf branch