code cleanup and nicer cmd argument.