Refactoring iPython Notebook support

DRYer, more semantic
Merge pull request #17 from singingwolfboy/ipython-notebook

Refactoring iPython Notebook support