Fix missing prototypes for HAVE_NS (caused crash) and vrious warnings.