Fix some edge conditions in the name function and command.