Handle crashes

This is related to #189. The original implementation can't work in a transaction (see #189 for details).

This implementation in this new PR is actually working and also much simpler.

I only did a quick test with it and looks like it is working perfectly.

Includes:
- [x] update mechanism for new database column or functions (and update the functions if required)
- [x] handling of crashed workers by unlocking their jobs upon starting of a new worker