Added additional comments and cleaned up some formatting