rearrange method in datamodel, add comments, fixed few small bugs