First pass at upgrade code