Fixed some bugs, added some tests, tweaked the package