Added comments, remove unnecessary code