Adding some mroe documentation and fixing some bugs