Fixed incorrect handling of the Completed state.