Fixing some formatting
Adding some comments and cleaning up.