Made some minor code changes. Better for ipython, and use logging instead of printing.