Fix unknown modes exception, code cleanup

Also use length of prefix when calculating max nicklen