Use log statements over print/sys.stdout

This also contains formatting and style cleanups