Add basic NICKNAMEINUSE handling

This has been tested and works alright :-)

Sorry about the extra merge commit, can you squash it?