This reverts commit dfdb91b429 and commit 188d766757. despite earlier assumptions the code is correct and there is likely a memory corruption elsewhere.
dfdb91b429
188d766757