More bugfixes for long polling task states. Fixed error that caused polling to continue after goal state had been reached.