Mostly small changes; fix stupid mistake in replicate.