Fixed formatting and a few code errors