Better documented, added some jUnit tests, improved functionality