Fix errors and formatting