Added the javadocs. Also made various design changes