Added initialisation of random seed and improved commenting.