Reformat code, add type annotation