cosmetic change.
ignore SIGPIPE.
make database handling thread safe.
remove an unused function.