add JavaDocs, make code more conventional