Added comments and some changes