Fix report of errors and creation if new values

While I'm here cleanup the code with PEP8.