Finished creating an example IPython notebook and cleaned up a bunch of code.

Added an IPython notebook showing how to run the code, and did a lot of code cleanup so that this would work well.