Add beforePin and beforeUnpin actions

Fixes #96.