Added complete Javadoc documentation, and a general code clean-up