Bug fixes, documentation added