Factor out GetLockPort and WaitforParentExit
Replace process synchronization mechanism
Add CheckMidUpgrade function