Optimize imports and Tidy up Code