Improve valgrind hooking, though I'm not sure if it's helpful yet