Optimize imports and reformat code