A bit of refactoring to clean up codec initialization