Fixed some bugs while doing lottery.