Fix issues 43 - error 500 on /api/sync

Fixes issues #43