(Mostly) cosmetic changes 

You may want to review:

a295ce1, the kind of code that make me feel uncomfortable with duck-typing :)
67f1e24, avoid to read two times the input file from disk