Minor optimizations to negative sampling.