Added a few more comments and removed some unused code