Add javadocs and some cleanup