Refactoring iPython Notebook support

DRYer, more semantic