Minor code cleanup, added more JavaDocs