Fixed some bugs
Autoformat code