Added comments and minor changes