updated javadoc and fixed threading issues