better duration counts and pidfile cleanup