clean up subprocess code