Multi-stage programming