Prevent fatal error when adding/updating
Merge pull request #22 from danmarsden/master

fix fatal error during add/update