Added index file generation, and some re-works to handle PE reads better.