Refactor and add the javdoc style comments