Added documentation and cleaned code
Added some documentation