Fix-up regainnick functionality + general code cleanup.