Format code and fix obvious issues