Doc updated and bugs fixed