Fix some bugs: terminal of xrange.