Better debug error handling
Fixed formatting