Made small change to the way random transitions are dealt with.