fixed divide by zero bugs and wait task bug