Fix reference video wrapping