Comments and formatting
Fixed some bugs also