Fix ugly and buggy code for argument appending

This code was buggy, also after the fixing merge. Sometimes it is better
to write more code to be clear what happens when.