fixed running and failed status.
Added detailed logging of the internal state.