make crt behave properly, hopefully fixing segfault on nixos; comment code thoroughly