Fixes #586 and #587
Merge pull request #588 from gustavofonseca/bug586

Corrige bug: TypeError: %d format: a number is required, not NoneType