WIP mainly because we *should* use thread locals, but #[thread_local] causes segfaults.
mentioned in commit e9295380