Format code and remove unused code