Clean up and add some comments
Clean up and add some comments