Added permutation codes
Fix random on G++ 4.6