Fix formatting and remove unused code.

This commit fixes various formatting issues and removes useless or unused imports, variables, and methods.