Some more fishing around the evil elves conspiracy
I wrote another shorter program, that just did the same piece of code at the same place. To write this was harder than expected (see this cry for help) for some more details or check out the gruesome project SimpleBestBugVerify.
In any case, as was sort of expected, the bug doesn't manifest itself there at all.
Unfortunately I can't reproduce the bug in the original code currently, because as fate has it, the certificate for the VPN that carries the database connection just expired and now it's christmas and the guy responsible for it (Hey Oli! ;)) might not be able to fix it so quickly.
It's like evil elves are conspiring against me, but I am used to that.