Import upstream code, apply changes