Fixed formatting
Cleaned up code, using a logger