Tweaking some code. Added tests. Updated readme.