Optimize imports, remove unused ones and tidy up