pep8 fixes
fix using %r instead of %s in error messages
fix the name...
make metadata printing more uniform
optimize logging in the inner-loop