Some refactoring; create JavaDocs