Some improvements of requesting pid of running instance code.