Add Java doc and some comments in code