fixing trimming and validating username in tsmain.cpp