Attempt at fixing StringIndexOutOfBounds exception in parseMessageType