Merge pull request #54 from piesync/races

Prevent races
Merge branch 'master' into zero-invoices