Remove unused code.
Add doc for intermediate data structure.