Added comments and some JavaDoc.