Added some comments and changed formatting.