Some random refactoring. No functionality change.
Embed python, and redirect stdout of python