NIF debugging with GDB/Valgrind

Use a debug emulator. Besides that it is just normal C debugging tactics.