Keep main pywhich code in a module, not directly in the script
Handle C modules without __file__ properly
Add docstrings
Fix up logging