Added some comments and removed some useless code.