Fix ensureHeader with index

Change-Id: I368ee7061e2de7b76768e7bc72a6ecfce66e0880
Merge remote-tracking branch 'koush/master'