Moved the particle code in Block.* to a separate function genParticles()