fixed fatal bugs with 'addpin' functionality