clean up and fix procedure check in impersonate_struct and chaperone_struct