Fix errors and warnings