def custom_bake_remap(scene):
    """
    Remap bake types into the new types and set the flags accordingly
    """
    bake_lookup = ('COMBINED', 'AO', 'SHADOW', 'NORMAL', 'UV', 'EMIT',
        'ENVIRONMENT', 'DIFFUSE_DIRECT', 'DIFFUSE_INDIRECT',
        'DIFFUSE_COLOR', 'GLOSSY_DIRECT', 'GLOSSY_INDIRECT', 'GLOSSY_COLOR',
        'TRANSMISSION_DIRECT', 'TRANSMISSION_INDIRECT',
        'TRANSMISSION_COLOR', 'SUBSURFACE_DIRECT', 'SUBSURFACE_INDIRECT',
        'SUBSURFACE_COLOR')
    diffuse_direct_idx = bake_lookup.index('DIFFUSE_DIRECT')
    cscene = scene.cycles
    bake_type_idx = cscene.get('bake_type')
    if bake_type_idx is None:
        cscene.bake_type = 'COMBINED'
        return
    if bake_type_idx < diffuse_direct_idx:
        return
    bake_type = bake_lookup[bake_type_idx]
    cscene.bake_type, end = bake_type.split('_')
    if end == 'DIRECT':
        scene.render.bake.use_pass_indirect = False
        scene.render.bake.use_pass_color = False
    elif end == 'INDIRECT':
        scene.render.bake.use_pass_direct = False
        scene.render.bake.use_pass_color = False
    elif end == 'COLOR':
        scene.render.bake.use_pass_direct = False
        scene.render.bake.use_pass_indirect = False
