Cleaned up indenting a bit and added some comments