Added comments and cleaned code.