Remove unnecessary code and add comments