add doc at index, and minor changes