Add a tutorial

Fixed a few bugs, documented by adding a tutorial