Added FSM for reading stanzas from stream in a right way.