Fixed the bug with qstat timer.

Fixed the timer and cleaned some code.