Fix broken db update routine

WIP, do not merge yet

Fixes #414