Some code fixes and documentation added