I neglected some info in James Dick's 'Songs of Robert Burns'. The last two verses of the song above are by Burns, and the rest (with some correction by Burns) he got from a clergyman, Mr. Cluny. Burns got Clarke, the music editor of SMM to note down the tune from Cluny's singing.