add extensive comments, rearrange code, add some components