Added missing javadoc + corrected some mistakes in the code