Remove unused code; add more comments