Add some comments and update some code formatting