Minor tweaks, randomization

Added randomization plus fixed some errors.