Clean up any invalid versions on startup in addition to fixing the version order.