Added javadoc documentation of each function + some comments