Fixed #9 and done some code formatting