adding comments
fixing some bugs, thanks Marco !!!