Use log statements over print/sys.stdout

Fixes #55.

This also contains formatting and style cleanups.