Added a bit of thread-safety and implemented MODE query and fixed the nick collision handling.