Closes #2. Completely working version.