Ensure we're writing to stderr in the builder

http://hydra.nixos.org/build/17862041
Fix some memory leaks
Shut up a Valgrind warning