fixes formatting of output and adds comments