Clean up some code, add a few tests and setup travis.