Added javadoc on all API classes and some bug fixing