Bug fix + faster execution of HMM rand