First thing to confirm is that you're using orc or arc if compiling with Nim 1.x, or that you're using Nim 2.0. Not sure what your compiler version and compile command looks like.
Second, I see some ref objects being referenced in multiple threads which is generally not doable. The ref count is not atomic so it cannot safely be used in this way. If you want a shared pointer type you may find <https://github.com/nim-lang/threading/blob/master/threading/smartptrs.nim> helpful or you'll want to use non-GC memory (manually managed).
