lightirc: fix a bunch of bugs

* fix NPEs and various other crashes
* also cleanup code a lot