Fix up privmsg and remove excessive usage of write.