Wrap sample update in transaction
Merge pull request #943 from JamesGlover/investigate_sm_bug

Wrap sample update in transaction