Updated code a bit and added a demo notebook.