Added some comments and updated some formatting