Reformat code, minor fixes