Fixed some little issues and formated the code