Fix broken db update routine

WIP, do not merge yet