Added more comments and various cleanup