Fully working example, and bug fixes to the library