add get_messages_by_index and some additional API tweaks