Add (index, length) parameters to messageReceived() and write()