Cleanup code and fix formatting issues.