mid bug fixed.
Javadocs added.