Fix indentation, rename variables, and use loggers