Added comments
Fixed some warnings and formatting