Fixed some issues
Reformat code