irc-write.c: Clean up code and add more documentation comments