Bug fixes to pin.set handler