Some refactoring in preparation for inline video