Fixed some bugs and formatting