Reformat, clean up and remove warnings