improve javadocs, more testing, formatting