Should this be BUFFER_SIZE - tx_len rahter than BUFFER_SIZE - tx_index?