Added comments and cleaned code
Added documentation