def process_legislator_data(raw_data):
    """
    Clean & (partially) flatten the legislator data
    Args:
        raw_data (list of nested dictionaries):
            Legislator data from 

    Returns:
        dict where key is Bioguide ID and values are legislator info
    """
    legislator_data = {}
    for leg in raw_data:
        speaker_id = leg["id"]["bioguide"]

        legislator_data[speaker_id] = {
            "first_name": leg["name"]["first"],
            "last_name": leg["name"]["last"],
            "gender": leg["bio"]["gender"],
            
            "terms": leg["terms"],
        }

    return legislator_data