Added cleanup code for dead pins