Remove unused code and fix comments