Added javadoc comments and some validation