Bugs fixed and doc updated