Add function remarks and some javadoc